<%@page import="POJO.SanPham"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="POJO.NguoiDung"%>
<%
    String name = "suaSanPham";
    String err = (String) session.getAttribute("id");
    if (err == "1")
    {
        // da dang nhap
        // Lấy loại người dùng
        NguoiDung nguoiDung = (NguoiDung) session
                .getAttribute("nguoiDung");
        if (!(nguoiDung.getLoai() == 2 || nguoiDung.getLoai() == 4))
        {
            RequestDispatcher dispatcher = request
                    .getRequestDispatcher("/view/Permission.jsp");
            dispatcher.forward(request, response);
        }
    }
    else
    {
        response.sendRedirect("login");
    }

    SanPham sp = (SanPham) request.getAttribute("sanPham");
    
  //Lấy ngày tháng năm
    String[] temp = sp.getNgayDang().split(" ");// Chuỗi lấy ra có dạng yyyy-MM-dd hh:mm:ss
    String[] ngthang = temp[0].split("-");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Thay đổi thông tin sản phẩm</title>
<link rel="stylesheet"
	href="http://localhost:8080/OnlineShop/css/style.css" type="text/css"
	media="all" />
</head>
<body>
	<!-- Header -->
	<div id="header"></div>
	<!-- End Header -->

	<!-- Container -->
	<div id="container">
		<div class="shell">

			<div id="main">
				<!-- Content -->
				<div id="content">

					<!-- Box -->
					<!-- End Box -->

					<!-- Box -->
					<div class="box">
						<!-- Box Head -->
						<div class="box-head">
							<h2>Thay đổi thông tin sản phẩm</h2>
						</div>
						<!-- End Box Head -->

						<form action="" method="post">

							<!-- Form -->
							<form method="post" action="SuaSanPham">
								<div class="form">
									<p>
										<span class="req">max 100 symbols</span> 
										<label>Tên sản phẩm<span>(không được để trống)</span></label> 
										<input type="text" class="field size1" name="<%out.print(name);%>" value="<%=sp.getTenSanPham()%>" />
									</p>

									<p class="inline-field">
										<label>Ngày đăng</label> 
										<input class="field size2" value="<%=ngthang[2]%>" name="<%out.print(name);%>"> </input> 
											<input class="field size2" value="<%=ngthang[1]%>"name="<%out.print(name);%>"> </input> 
											<input class="field size2" value="<%=ngthang[0]%>" name="<%out.print(name);%>"></input>
									</p>

									<p>
										<span class="req">max 100 symbols</span> <label>Mô tả<span>(bắt
												buộc)</span></label>
										<textarea class="field size1" rows="2" cols="30"
											name="<%out.print(name);%>"><%=sp.getMoTa()%></textarea>
									</p>
									<p>
										<label>Đơn giá<span>(bắt buộc)</span></label> <input
											type="text" class="field size1" name="<%out.print(name);%>"
											value="<%=sp.getDonGia()%>" />
									</p>
									<p>
										<label>Số lượng tối thiểu<span>(bắt buộc)</span></label> <input
											type="text" class="field size1" name="<%out.print(name);%>"
											value="<%=sp.getSoLuongToiThieu()%>" />
									</p>
									<p>
										<label>Số lượng tồn<span>(bắt buộc)</span></label> <input
											type="text" class="field size1" name="<%out.print(name);%>"
											value="<%=sp.getSoLuongTon()%>" />
									</p>
									<p>
										<label>Tình trạng<span>(bắt buộc)</span></label> <input
											type="text" class="field size1" name="<%out.print(name);%>"
											value="<%=sp.getTinhTrang()%>" />
									</p>
									<p>
										<label>Mã danh mục<span>(bắt buộc)</span></label> <input
											type="text" class="field size1" name="<%out.print(name);%>"
											value="<%=sp.getMaDanhMuc()%>" /> <input type="hidden"
											class="field size1" name="<%out.print(name);%>"
											value="<%=sp.getMaSanPham()%>" />
									</p>
									<p>
										<input type="submit" class="button" value="Submit" />
									</p>
								</div>
							</form>
							<!-- End Form -->

							<!-- Form Buttons -->

							<!-- End Form Buttons -->
						</form>
					</div>
					<!-- End Box -->

				</div>
				<!-- End Content -->

				<!-- Sidebar -->
				<!-- End Sidebar -->

				<div class="cl">&nbsp;</div>
			</div>
			<!-- Main -->
		</div>
	</div>
	<!-- End Container -->

	<!-- Footer -->
	<div id="footer">
		<div class="shell">
			<span class="left">&copy; 2010 - CompanyName</span> <span
				class="right"> Design by <a href="http://chocotemplates.com"
				target="_blank" title="The Sweetest CSS Templates WorldWide">Chocotemplates.com</a>
			</span>
		</div>
	</div>
	<!-- End Footer -->

</body>
</html>